<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="数据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataDt">
              <j-date placeholder="请输入数据日期" v-model="model.dataDt"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txje">
              <a-input-number v-model="model.txje" placeholder="请输入贴现金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现金额折人民币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txjezrmb">
              <a-input-number v-model="model.txjezrmb" placeholder="请输入贴现金额折人民币" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现利率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txll">
              <a-input-number v-model="model.txll" placeholder="请输入贴现利率" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贷款质量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dkzl">
              <a-input v-model="model.dkzl" placeholder="请输入贷款质量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贷款状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dkzt">
              <a-input v-model="model.dkzt" placeholder="请输入贷款状态"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="科目代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectNo">
              <a-input v-model="model.subjectNo" placeholder="请输入科目代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khmc">
              <a-input v-model="model.khmc" placeholder="请输入客户名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="客户代科目名称码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="khdm">
              <a-input v-model="model.khdm" placeholder="请输入客户代科目名称码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="科目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectName">
              <a-input v-model="model.subjectName" placeholder="请输入科目名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="金融机构代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jrjgdm">
              <a-input v-model="model.jrjgdm" placeholder="请输入金融机构代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="内部机构号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nbjghm">
              <a-input v-model="model.nbjghm" placeholder="请输入内部机构号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="金融机构地区代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jrjgdqdm">
              <a-input v-model="model.jrjgdqdm" placeholder="请输入金融机构地区代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txfs">
              <a-input v-model="model.txfs" placeholder="请输入贴现方式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="票据种类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pjzl">
              <a-input v-model="model.pjzl" placeholder="请输入票据种类"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="票据介质" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pjjz">
              <a-input v-model="model.pjjz" placeholder="请输入票据介质"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="票据编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pjbh">
              <a-input v-model="model.pjbh" placeholder="请输入票据编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现申请人证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txsqrzjlx">
              <a-input v-model="model.txsqrzjlx" placeholder="请输入贴现申请人证件类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现申请人证件代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txsqrzjdm">
              <a-input v-model="model.txsqrzjdm" placeholder="请输入贴现申请人证件代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现申请人国民经济部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txsqrgmjjbm">
              <a-input v-model="model.txsqrgmjjbm" placeholder="请输入贴现申请人国民经济部门"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现申请人行业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txsqrhy">
              <a-input v-model="model.txsqrhy" placeholder="请输入贴现申请人行业"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现申请人地区代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txsqrdqdm">
              <a-input v-model="model.txsqrdqdm" placeholder="请输入贴现申请人地区代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现申请人经济成分" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txsqrjjcf">
              <a-input v-model="model.txsqrjjcf" placeholder="请输入贴现申请人经济成分"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现申请人企业规模" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txsqrqygm">
              <a-input v-model="model.txsqrqygm" placeholder="请输入贴现申请人企业规模"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="承兑人名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cdrmc">
              <a-input v-model="model.cdrmc" placeholder="请输入承兑人名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="承兑人证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cdrzjlx">
              <a-input v-model="model.cdrzjlx" placeholder="请输入承兑人证件类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="承兑人证件代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cdrzjdm">
              <a-input v-model="model.cdrzjdm" placeholder="请输入承兑人证件代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="出票人名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cprmc">
              <a-input v-model="model.cprmc" placeholder="请输入出票人名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="出票人证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cprzjlx">
              <a-input v-model="model.cprzjlx" placeholder="请输入出票人证件类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="出票人证件代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cprzjdm">
              <a-input v-model="model.cprzjdm" placeholder="请输入出票人证件代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="出票日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cprq">
              <j-date placeholder="请输入出票日期" v-model="model.cprq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="票据到期日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pjdqrq">
              <j-date placeholder="请输入票据到期日期" v-model="model.pjdqrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-form-model-item label="交易日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jyrq">
              <j-date placeholder="请输入交易日期" v-model="model.jyrq"  style="width: 100%" />
            </a-form-model-item>
          <a-col :span="12">
            <a-form-model-item label="币种" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bz">
              <a-input v-model="model.bz" placeholder="请输入币种"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="票面金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pmje">
              <a-input-number v-model="model.pmje" placeholder="请输入票面金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="票面金额折人民币" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pmjezrmb">
              <a-input-number v-model="model.pmjezrmb" placeholder="请输入票面金额折人民币" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="贴现币种" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="txbz">
              <a-input v-model="model.txbz" placeholder="请输入贴现币种"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'JsPBillFinaInfForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/jsPBillFinaInf/jsPBillFinaInf/add",
          edit: "/jsPBillFinaInf/jsPBillFinaInf/edit",
          queryById: "/jsPBillFinaInf/jsPBillFinaInf/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>
